//
//  ForumTableViewCell.m
//  CarFace
//
//  Created by dlios on 15-3-24.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "ForumTableViewCell.h"

@implementation ForumTableViewCell

- (void)dealloc
{
    [_photoView release];
    [_titleLabel release];
    [_themeLable release];
    [_numberLable release];
    [super dealloc];
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.photoView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.photoView];
        [_photoView release];
        
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.textAlignment = NSTextAlignmentLeft;
        self.titleLabel.font = [UIFont systemFontOfSize:16.0f];
        self.titleLabel.numberOfLines = 0;
        [self.contentView addSubview:self.titleLabel];
        [_titleLabel release];
        
        self.themeLable = [[UILabel alloc] init];
        self.themeLable.textAlignment = NSTextAlignmentLeft;
        self.themeLable.font = [UIFont systemFontOfSize:12.0f];
        self.themeLable.textColor = [UIColor grayColor];
        [self.contentView addSubview:self.themeLable];
        [_themeLable release];
        
        self.numberLable = [[UILabel alloc] init];
        self.numberLable.textAlignment = NSTextAlignmentRight;
        self.numberLable.font = [UIFont systemFontOfSize:12.0f];
        self.numberLable.textColor = [UIColor grayColor];
        [self.contentView addSubview:self.numberLable];
        [_numberLable release];
        
    }
    return self;
    
}



- (void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat width = self.contentView.bounds.size.width;
    CGFloat height = self.contentView.bounds.size.height;
    self.photoView.frame = CGRectMake(7, 5, width / 3 - 15, height - 10);
    self.titleLabel.frame = CGRectMake((width / 3) + 10 , 7, (width * 2 / 3) - (width / 6 - 35), height / 2);
    self.themeLable.frame = CGRectMake((width / 3) + 10, height / 2 + 15, width / 3 + 20, height / 4);
    self.numberLable.frame = CGRectMake((width  * 2 / 3) + 50, height / 2 + 15, width / 6 - 10, height / 4);
    
    NSString *smallpicStr = self.forum.smallpic;
    NSURL *url = [NSURL URLWithString:smallpicStr];
    [self.photoView setImageWithURL:url];
    
    self.titleLabel.text = self.forum.title;
    self.themeLable.text = self.forum.bbsname;
    NSString *string = [NSString stringWithFormat:@"%@", self.forum.replycounts];
    self.numberLable.text = [string stringByAppendingString:@"回"];
    
//    NSLog(@"%@***** %@ ******%@ *****", self.titleLabel.text, self.themeLable.text, self.numberLable.text);
    
}











- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
